package cn.com.headfree.util;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;

import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;

@Configuration
public class BeanConfig {
	 @Autowired
	    private ObjectFactory<HttpMessageConverters> messageConverters;

	    @Scope("prototype")
	    @Primary
	    @Bean
	    public Encoder feignFormecoder(){
	        return new SpringFormEncoder(new SpringEncoder(messageConverters));
	    }

}
